function getName() {
    var user=JSON.parse(localStorage.getItem("loggedinUser"));

    if (user) {
        console.log("Currently logged in: " + user["name"]);
        document.getElementById("name-goes-here").innerText = user["name"];
        } else {
        console.log("No one is logged in");
        }
}
getName(); //run the function